import request from "@/utils/request";
import type {
  GetTrademarkListResponse,
  TrademarkItem,
  TrademarkList,
} from "./model/trademarkModel";

// 枚举
const enum API {
  getTradeMarkList = "/admin/product/baseTrademark",
  addTradeMark = "/admin/product/baseTrademark/save",
  updateTradeMark = "/admin/product/baseTrademark/update",
  delTradeMarkApi = "/admin/product/baseTrademark/remove",
  getAllTradeMarkList = "/admin/product/baseTrademark/getTrademarkList",
}

/**
 * 请求品牌数据
 * @param page 当前页数
 * @param limit 每页条数
 * @returns getTradeMarkListResponse
 */
export const getTradeMarkListApi = (page: number, limit: number) => {
  return request.get<any, GetTrademarkListResponse>(
    API.getTradeMarkList + `/${page}/${limit}`
  );
};

/**
 * 添加品牌
 * @param data {}
 * @returns
 */
export const addTradeMarkApi = (data: TrademarkItem) => {
  return request.post<any, null>(API.addTradeMark, data);
};

/**
 * 修改品牌
 * @param data {}
 * @returns
 */
export const updateTradeMarkApi = (data: TrademarkItem) => {
  return request.put<any, null>(API.updateTradeMark, data);
};

/**
 * 删除品牌
 * @param id 品牌id
 * @returns null
 */
export const delTradeMarkApi = (id: number) => {
  return request.delete<any, null>(API.delTradeMarkApi + `/${id}`);
};

/**
 * 获取SPU品牌管理数据
 * @returns
 */
export const getAllTradeMarkListApi = () => {
  return request.get<any, TrademarkList>(API.getAllTradeMarkList);
};
